package com.foreknow.elm.service.impl;

import com.foreknow.elm.dao.BusinessDao;
import com.foreknow.elm.dao.impl.BusinessDaoImpl;
import com.foreknow.elm.po.Business;
import com.foreknow.elm.service.BusinessService;
import com.foreknow.elm.util.DBUtil;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class BusinessServiceImpl implements BusinessService {
    @Override
    public List<Business> listBusinessByOrderTypeId(Integer orderTypeId) {
        List<Business> list = new ArrayList<>();
        BusinessDao businessDao = new BusinessDaoImpl();
        try {
            list = businessDao.listBusinessByOrderTypeId(orderTypeId);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close();
        }
        return list;
    }

    @Override
    public Business getBusinessById(Integer businessId) {
        Business business = new Business();
        BusinessDao businessDao = new BusinessDaoImpl();
        try {
            business = businessDao.getBusinessById(businessId);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            DBUtil.close();
        }
        return business;
    }
}
